<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%
	String path2 = request.getContextPath();
	String basePath2 = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path2 + "/";
%>
<%--查询分车的列表c--%>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<script type="text/javascript"
	src="<%=path2%>/HoganJS/handlebars-v4.0.11.js"></script>
<title>Insert title here</title>
<style type="text/css">
li span {
	margin-left: 0px;
	cursor: pointer;
}

li span:hover {
	color: #427dff
}

.modal-data1,.modal-data2 {
	visibility: hidden;
	z-index: 1001;
	min-height: 300px;
	margin: 100px auto;
	background-color: #FFFFFF;
	-moz-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
	-webkit-box-shadow: 0 10px 20px #8AC1E2 inset, 0 -10px 0 #57a0ff inset;
	box-shadow: 0 10px 20px #57a1ff inset, 0 -10px 0 #57a0ff inset;
	padding: 5px;
	text-align: center;
	position: fixed;
	left: 22%;
}

 .loading {
            margin: 100px 450px;
            display: block;
            width: 65px;
            height: 65px;
            border: 1px solid #ddd;
            border-radius: 5px;
            opacity: .7;
            background: url(../images/loading.gif) no-repeat;
        }
.jx td input[type=checkbox]{width: 15px}
</style>
</head>
<body>
	<div id="modal-overlay"></div>
	<div class="modal-data1">
		<div style="height: 60px">
			<ul>
				<li
					style="text-align: left; margin-left: 60px; height: 40px; line-height: 40px">
					<span>车型：</span> <span> <input class="name" type="text">
				</span> <span>车牌号码：</span> <span> <input class="fnumber" type="text">
				</span> <span>
						<button class="findBtn1">查询</button>
				</span>
				</li>
			</ul>
		</div>
		<div style="width: 1100px; height: 350px; overflow: scroll;">
			<form action="">
				<table class="head1"
					style="width: auto; white-space: nowrap; border-spacing: 0px">
					<tr style="background: #f2f2f2; height: 30px; line-height: 20px;"
						class="sel">
						<td style="width: 20px"></td>
						<td>车型</td>
						<td>车牌号码</td>
						<td>简称</td>
						<td>描述</td>
						<td>创建时间</td>
						<td>用户名</td>
						<td>最后修改时间</td>
						<td>用户名</td>
						<td>财务组织</td>
						<td>入户日期</td>
						<td>车架号</td>
						<td>发动机号</td>
						<td>年检到期日</td>
						<td>交强险到期日</td>
						<td>商业险到期日</td>
						<td>二级维护到期日</td>
						<td>综检到期日</td>
						<td>保养到期日</td>
						<td>科目三通行证到期日</td>
						<td>所属机构</td>
						<td>产地</td>
						<td>品牌</td>
						<td>保单号</td>
						<td>商业险日期</td>
						<td>交强险日期</td>
						<td>年检日期</td>
						<td>二级维护日期</td>
						<td>综检险日期</td>
						<td>保养日期</td>
						<td>科目三通行证日期</td>
						<td>购买价格</td>
						<td>购买日期</td>
						<td>理论油耗</td>
					</tr>
					<c:forEach items="${cars}" var="cars">
						<tr style="margin-top: 45px" class="xysj">
							<td style="width: 20px" class="td"><input type="checkbox" class="check"
								value="${cars.fid}" name="train" style="width: 15px" /></td>
							<td>${cars.fnameL2}</td>
							<td>${cars.fnumber}</td>
							<td>${cars.fsimplename}</td>
							<td>${cars.fdescriptionL2}</td>
							<td>${cars.fcreatetime}</td>
							<td>${cars.createName}</td>
							<td>${cars.flastupdatetime}</td>
							<td>${cars.updateName}</td>
							<td>${cars.companyName}</td>
							<td>${cars.cfrhrq}</td>
							<td>${cars.cfcjh}</td>
							<td>${cars.cffdjh}</td>
							<td>${cars.cfnjdqr}</td>
							<td>${cars.cfjqxdqr}</td>
							<td>${cars.cfsyxdqr}</td>
							<td>${cars.cfejwhdqr}</td>
							<td>${cars.cfzjdqr}</td>
							<td>${cars.cfbydqr}</td>
							<td>${cars.cfkmstxzdqr}</td>
							<td>${cars.deptName}</td>
							<td>${cars.cfcd}</td>
							<td>${cars.cfpp}</td>
							<td>${cars.cfbdh}</td>
							<td>${cars.cfsyxrq}</td>
							<td>${cars.cfjqxrq}</td>
							<td>${cars.cfnjrq}</td>
							<td>${cars.cfejwhrq}</td>
							<td>${cars.cfzjrq}</td>
							<td>${cars.cfbyrq}</td>
							<td>${cars.cfkmstxzrq}</td>
							<td>${cars.cfgmjg}</td>
							<td>${cars.cfgmrq}</td>
							<td>${cars.cfllyh}</td>
						</tr>
					</c:forEach>
				</table>
			</form>
		</div>
		<button class="subtn1"
			style="width: 200px; position: absolute; bottom: 25px; font-size: 16px; left: 170px">
			确定</button>
		<button class="btn"
			style="width: 200px; position: absolute; bottom: 25px; font-size: 16px; right: 170px">
			关闭</button>
	</div>
	<div class="modal-data2">
	<input type="hidden" >
	</div>
	<script type="text/javascript" src="<%=path2%>/JQuery/jquery-1.8.2.js"></script>
	<script id="table-template" type="text/x-handlebars-template">

		<div style="height: 60px">
			<ul>
				 <li  style="text-align: left;margin-left: 60px;height: 40px;line-height: 40px">
				  		<span>名称：</span>
				  		<span>
				  		 	<input class="name2" type="text" >
				  		</span>
				  		<span>
				  			<button class="findBtn2">
				  				查询
				  			</button>
				  		</span>
				  	</li>
			</ul>
		</div>
		<div style="width:1100px; height:350px; overflow:scroll;">
			<form action="">
				 <table class="head2" style="width: auto;white-space:nowrap;border-spacing: 0px">
				    <tr style="background: #f2f2f2;height: 30px;line-height: 20px;" class="sel">
					        <td style="width: 20px"></td> 
					        <td>名称</td>
					        <td>编码</td>
					        <td>简称</td>
					        <td>描述</td>
					        <td>创建时间</td>
					        <td>用户名</td>
					        <td>最后修改时间</td>
					        <td>用户名</td>
					        <td>财务组织</td>
					        <td>单价</td>
					        <td>工时</td>
					        <td>修理厂</td>
				   </tr>
    					{{#each this}}
    				<tr class="jx">
        					<td><input type="checkbox" value="{{fid}}" name="train2"/></td>
        					<td>{{fnameL2}}</td>
        					<td>{{fnumber}}</td>
       						<td>{{fsimplename}}</td>
        					<td>{{fdescriptionL2}}</td>
        					<td>{{fcreatetime}}</td>
        					<td>{{createName}}</td>
        					<td>{{flastupdatetime}}</td>
        					<td>{{updateName}}</td>
        					<td>{{companyName}}</td>
        					<td class="gs">{{cfprice}}</td>
        					<td class="dj">{{cfmanhours}}</td>
        					<td>{{repairshop}}</td>
    				</tr>
    		{{/each }}
 			</table>
		</form>
	</div>
		<button class="subtn2" style="width: 150px;position: absolute;bottom: 25px;font-size: 16px;left: 280px">
				      确定
		</button>
		<button class="btn" style="width: 150px;position: absolute;bottom: 25px;font-size: 16px;right: 280px">
				    关闭
		</button>
</script>
<script type="text/javascript">

//弹出框模版文件
var myTemplate = Handlebars.compile($("#table-template").html());

//注册一个比较内容是否为空
Handlebars.registerHelper("isNull", function (v1, options) {
    if (v1 != "") {
        //满足添加继续执行
        return options.fn(this);
    } else {
        //不满足条件执行{{else}}部分
        return options.inverse(this);
    }
});

//注册一个比较大小的Helper,判断v1是否大于v2
Handlebars.registerHelper("compare", function (v1, v2, options) {
    if (v2 == 100) {
        //满足添加继续执行
        return options.fn(this);
    }
    if (v1 == v2) {
        //满足添加继续执行
        return options.fn(this);
    } else {
        //不满足条件执行{{else}}部分
        return options.inverse(this);
    }
});

var tm = "";
//维修项目弹窗
function cfminame2 (_this){
	    var jx = _this.parent().parent().prop("class");
		$(".stu").val(jx)
		$('#modal-overlay').css('visibility','visible')
		$('.modal-data2').css('visibility','visible')
		
		if(tm == ""){
			$('.modal-data2').html("<div class='loading'></div>");
			 $.ajax({
					url: '<%=path2%>/DrivingSys/selMaintainItems',
			        type: "post",
			        data: {},
			        dataType: "json",
			        success:function(json){
			        	//alert(json.length)
			        	$('.modal-data2').html(myTemplate(json));
			        	tm = "tm";
			        },
		       	error: function(){alert('错误');} 
		    })
		}else{
			
		}
} 
//根据名称查询维修项目弹窗
$(".findBtn2").live('click',function(){
	var name = $(".name2").val();
	$('.head2').html("<div class='loading'></div>");
	$.ajax({
		url: '<%=path2%>/DrivingSys/selMaintainItems',
        type: "post",
        data: {'name':name},
        dataType: "json",
        success:function(json){
        	$('.modal-data2').html(myTemplate(json));
        	$(".name2").val(name)
        },
   	error: function(){alert('错误');} 
})
})

//根据名称查询车辆
$('.findBtn1').click(function(){
	 var name=$('.name').val()
	 var fnumber = $(".fnumber").val();
		 $.ajax({
			    url:'<%=path2%>/DrivingSys/queryCarByInfo',
				type : "post",
				data : {'name' : name,'fnumber' : fnumber},
				dataType : "json",
				success : function(json) {
							var str = ''
						for (var i = 0; i < json.length; i++) {
								str += '<tr style="margin-top: 45px;height: 30px;" class="xysj"><td><input style="width: 15px;height: 15px" '
	  	             			str+='type="checkbox" name="train"  value="'+json[i].fid+'"></td>'
								if (json[i].fnameL2 == null) {
										str += '<td></td>'
								} else {
									str += '<td>'+ json[i].fnameL2+ '</td>'
								}
								if (json[i].fnumber == null) {
										str += '<td></td>'
								} else{
										str += '<td>'+ json[i].fnumber+ '</td>'
								}
								if (json[i].fsimplename != null) {
										str += '<td>'+ json[i].fsimplename+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].fdescriptionL2 != null) {
									str += '<td>'+ json[i].fdescriptionL2+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].fcreatetime != null) {
									str += '<td>'+ json[i].fcreatetime+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].createName != null) {
									str += '<td>'+ json[i].createName+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].flastupdatetime != null) {
									str += '<td>'+ json[i].flastupdatetime+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].updateName != null) {
									str += '<td>'+ json[i].updateName+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].companyName != null) {
									str += '<td>'+ json[i].companyName+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfrhrq != null) {
									str += '<td>'+ json[i].cfrhrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfcjh != null) {
									str += '<td>'+ json[i].cfcjh+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cffdjh != null) {
									str += '<td>'+ json[i].cffdjh+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfnjdqr != null) {
									str += '<td>'+ json[i].cfnjdqr+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfjqxdqr != null) {
									str += '<td>'+ json[i].cfjqxdqr+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfsyxdqr != null) {
									str += '<td>'+ json[i].cfsyxdqr+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfejwhdqr != null) {
									str += '<td>'+ json[i].cfejwhdqr+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfzjdqr != null) {
									str += '<td>'+ json[i].cfzjdqr+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfbydqr != null) {
									str += '<td>'+ json[i].cfbydqr+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfkmstxzdqr != null) {
									str += '<td>'+ json[i].cfkmstxzdqr+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].deptName != null) {
									str += '<td>'+ json[i].deptName+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfcd != null) {
									str += '<td>'+ json[i].cfcd+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfpp != null) {
									str += '<td>'+ json[i].cfpp+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfbdh != null) {
									str += '<td>'+ json[i].cfbdh+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfsyxrq != null) {
									str += '<td>'+ json[i].cfsyxrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfjqxrq != null) {
									str += '<td>'+ json[i].cfjqxrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfnjrq != null) {
									str += '<td>'+ json[i].cfnjrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfejwhrq != null) {
									str += '<td>'+ json[i].cfejwhrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfzjrq != null) {
									str += '<td>'+ json[i].cfzjrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfbyrq != null) {
									str += '<td>'+ json[i].cfbyrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfkmstxzrq != null) {
									str += '<td>'+ json[i].cfkmstxzrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfgmjg != null) {
									str += '<td>'+ json[i].cfgmjg+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfgmrq != null) {
									str += '<td>'+ json[i].cfgmrq+ '</td>'
								} else {
									str += '<td></td>'
								}
								if (json[i].cfllyh != null) {
									str += '<td>'+ json[i].cfllyh+ '</td>'
								} else {
									str += '<td></td>'
								}
								str += '</tr>';
							}
							$(".head1 tr:not(':first')").remove()
							$('.head1').append(str)
							},
							error : function() {
									alert('错误');
							}
						});
					})
	</script>
</body>
</html>